package com.zjjt.dc.modules.srv.controller.lw;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zjjt.dc.common.api.CommonResult;
import com.zjjt.dc.modules.datacatch.dto.LwWhDTO;
import com.zjjt.dc.modules.datacatch.entity.lw.DcCatchDataLwPriceDr;
import com.zjjt.dc.modules.datacatch.vo.lw.DcCatchDataLwPriceVO;
import com.zjjt.dc.modules.datacatch.vo.lw.LwWhVO;
import com.zjjt.dc.modules.srv.service.lw.ILWPriceService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "辽文数据核对")
@Tag(name = "LWController", description = "辽文数据核对")
@RequestMapping("/liaowen/outApi")
public class LwOutApiController {

    @Resource
    private ILWPriceService lwService;

    @RequestMapping(value = "/data", method = RequestMethod.POST)
    public CommonResult<?> review(String req) {
        // 解码
        byte[] decodedBytes = Base64.getDecoder().decode(req);
        String decodedString = new String(decodedBytes, StandardCharsets.UTF_8);

        List<LwWhVO> list = lwService.getLwWhVO(JSONObject.parseObject(decodedString, LwWhDTO.class));

        String jsonString = JSONArray.toJSONString(list);
        String res = Base64.getEncoder().encodeToString(jsonString.getBytes(StandardCharsets.UTF_8));
        return CommonResult.success(res);
    }


}
